package xyz.jcat.webmvc.serializer;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

import java.io.IOException;

public class LongJsonSerializer extends JsonSerializer<Long> {

    @Override
    public void serialize(Long value, JsonGenerator jsonGenerator,
                          SerializerProvider serializerProvider) throws IOException {
        String str = value == null ? null : value.toString();
        if(str != null) {
            jsonGenerator.writeString(str);
        }
    }
}
